const usersDao=require('../dao/usersDao');

//拿到所有 users
module.exports.find=async function(userObj,page){
    console.log(userObj,page,'service');
    return await usersDao.find(userObj,page)
}
// id 拿 user
module.exports.findById=async function (id){
try{
    return await usersDao.findById(id);
}catch(e){
    return{};
}

}
// post user
module.exports.insert=async function(userObj){
    return await usersDao.insert(userObj)
}

// update user
module.exports.update=async function(id,userObj){
    return await usersDao.update(id,userObj)
}
// 查询用户是否存在
module.exports.findOneId=async function(username){
    return await usersDao.findOneId(username)
}
// delete user
module.exports.delete=async function(id){
    try{
        return await usersDao.delete(id);
    }catch(e){
        return {};
    }
}

